<template>
     <div><el-dialog title="新增用户" :visible.sync="adsw">
		  <el-form :model="adlist">
		    <el-form-item label="名称" prop="name" :label-width="formLabelWidth">
		      <el-input v-model="adlist.name"  autocomplete="off"></el-input>
		    </el-form-item>
		    <el-form-item label="手机号" :label-width="formLabelWidth">
		      <el-input v-model="adlist.phone" autocomplete="off"></el-input>
		    </el-form-item>
		    <el-form-item label="地址" :label-width="formLabelWidth">
		      <el-input v-model="adlist.address" autocomplete="off"></el-input>
		    </el-form-item>
		    <el-form-item label="登录名称" :label-width="formLabelWidth">
		      <el-input v-model="adlist.username" autocomplete="off"></el-input>
		    </el-form-item>
		    <el-form-item label="登录密码" :label-width="formLabelWidth">
		      <el-input v-model="adlist.password" type="password" autocomplete="off"></el-input>
		    </el-form-item>
		    <el-form-item label="状态" :label-width="formLabelWidth">
                <el-radio v-model="adlist.enabled" label="1">在线</el-radio>
                <el-radio v-model="adlist.enabled" label="0">离线</el-radio>
		      <!-- <el-input v-model="adlist.enabled" autocomplete="off"></el-input> -->
		    </el-form-item>
		    <el-form-item label="家庭电话" :label-width="formLabelWidth">
		      <el-input v-model="adlist.telephone" autocomplete="off"></el-input>
		    </el-form-item>
		  </el-form>
		  <div slot="footer" class="dialog-footer">
		    <el-button @click="qxadsw">取 消</el-button>
		    <el-button type="primary" @click="adda">确 定</el-button>
		  </div>
  </el-dialog>
</div>
</template>
<!-- 分界线 -->
<script>
import axios from "axios";
var zhu = {
  adlist: {},
  adsw:true,
  model:'',
  formLabelWidth: "120px",
  url:"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
  pageList: {}


};
export default {
  name: "list",
  props: {
    msg: String
  },
  data() {
    // rules: {
    //       name: [
    //         { required: true, message: '请输入名称', trigger: 'blur' },
    //         { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
    //       ]
          // phone: [
          //   { required: true, message: '请输入手机号', trigger: 'blur' },
          //   { min: 0, max: 11, message: '长度在 0 到 11 个数字', trigger: 'blur' }
          // ],
          // address: [
          //   { required: true, message: '请输入地址', trigger: 'blur' },
          //   { min: 0, max: 50, message: '长度在 0 到 50 个字符', trigger: 'blur' }
          // ],
          // username: [
          //   { required: true, message: '请输入登陆名称', trigger: 'blur' },
          //   { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          // ],
          // password: [
          //    { required: true, message: '请输入登录密码', trigger: 'blur' },
          //   { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          // ],
          // telephone: [
          //    { required: true, message: '请输入家庭电话号', trigger: 'blur' },
          //   { min: 0, max: 11, message: '长度在 0 到 11 个字符', trigger: 'blur' }
          // ]
        // }
    return zhu;
  },
  mounted: function() {
    this.adsw = true;
  },
  methods: {
    adda: function() {
       alert("你好，很高兴为您服务！！！");
        console.log(this.adlist);
        var k = this;
        k.$ajax({
          mounted: "get",
           url: "http://localhost:8081/user/useradd",
           params: this.adlist
        }).then(function(q){
            if(q){
             alert("，您好，恭喜你新增成功！！！");
             now.$router.replace({path: '/user'});
            }
             alert("，您好，很抱歉你新增失败！！！");
             this.$router.replace({path: '/user'});
        });
    },
    qxadsw: function(){
        this.adlist = [];
        this.adsw = false;
        alert("你好，你慢走！！！");
       this.$router.replace({path: '/user'});
    }
  }
};
</script>